<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<ui:composition>
	<a4j:form id="form">
		<h:panelGrid columns="2" columnClasses="top , top">
			<rich:extendedDataTable value="#{companyBean.itemsDataModel}"
				var="item" id="table" width="340px" height="290px"
				sortMode="#{extendedTableBean.sortMode}"
				selectionMode="#{companyBean.selectionMode}"
				tableState="#{companyBean.tableState}"
				selection="#{companyBean.selection}"
				rows="50">
				<rich:column sortable="true" sortBy="#{item.name}" id="col_1"
					filterBy="#{item.name}" filterEvent="onkeyup"  width="170px"
					label="Name">
					<f:facet name="header">
						<h:outputText value="#{bundle['entities.company.name']}" id="header_item_1" />
					</f:facet>
					<h:outputText value="#{item.name}" id="item_1" />
				</rich:column>
				<rich:column sortable="true" sortBy="#{item.ico}" id="col_2"
					filterBy="#{item.ico}" filterEvent="onkeyup" width="170px"
					label="Ico">
					<f:facet name="header">
						<h:outputText value="#{bundle['entities.company.ico']}" id="header_item_2" />
					</f:facet>
					<h:outputText value="#{item.ico}" id="item_2" />
				</rich:column>
				<a4j:support reRender="companyBean_selectiontable"
					id="companyBean_take_selection" action="#{companyBean.takeSelection}"
					event="onselectionchange" />
			</rich:extendedDataTable>
			<h:panelGroup layout="block" style="width:500px">
				<rich:panel>
					<f:facet name="header">
						<h:outputText value="#{bundle['windows.sortSelectionModes.title']}" />
					</f:facet>
					<h:panelGrid columns="2">
						<h:outputText value="#{bundle['windows.sortSelectionModes.sortMode']}" />
						<h:selectOneMenu value="#{companyBean.sortMode}">
							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.sortMode.Single']}" itemValue="single" />
							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.sortMode.Multi']}" itemValue="multi" />
							<a4j:support event="onchange" ajaxSingle="true" reRender="table"
								id="support_sort_onchange" />
						</h:selectOneMenu>
						<h:outputText value="#{bundle['windows.sortSelectionModes.selectionMode']}" />
						<h:selectOneMenu value="#{companyBean.selectionMode}">
							<a4j:support ajaxSingle="true" event="onchange" reRender="table"
								id="support_select_onchange" />
							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.selectionMode.Single']}" itemValue="single" />
							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.selectionMode.Multi']}" itemValue="multi" />
							<f:selectItem itemLabel="#{bundle['windows.sortSelectionModes.selectionMode.None']}" itemValue="none" />
						</h:selectOneMenu>
					</h:panelGrid>
				</rich:panel>
			    <rich:panel>
			        <f:facet name="header">
			            <h:outputText value="#{bundle['windows.entities.company.Actions']}"></h:outputText>
			        </f:facet>
			            <a4j:commandButton action="#{companyBean.removeSelected}" value="#{bundle['entities.removeSelectedRecords']}"  reRender="table,companyBean_selectiontable"/>
			    </rich:panel>
			    <rich:panel>
			        <f:facet name="header">
			            <h:outputText value="#{bundle['windows.entities.company.NewEntity']}"></h:outputText>
			        </f:facet>
			        <h:panelGrid columns="2">
			            <h:outputText value="#{bundle['entities.company.name']}"/>
			            <rich:inplaceInput defaultLabel="click to enter new company name" value="#{companyBean.newCompany.name}" />
			            <h:outputText value="#{bundle['entities.company.ico']}"/>
			            <rich:inplaceInput defaultLabel="click to enter new company registration ID" value="#{companyBean.newCompany.ico}" />
			            <a4j:commandButton action="#{companyBean.createNew}" value="#{bundle['entities.createNewRecord']}" reRender="table,companyBean_selectiontable"/>
			        </h:panelGrid>
				</rich:panel>
			</h:panelGroup>
		</h:panelGrid>

		<rich:panel>
			<f:facet name="header">
				<h:outputText value="#{bundle['windows.currentlySelected.title']}" />
			</f:facet>
			<rich:dataTable value="#{companyBean.selectedItems}" var="sel"
				id="companyBean_selectiontable">
				<rich:column width="200px">
					<h:outputText value="#{sel.name}" />
				</rich:column>
				<rich:column width="200px">
					<h:outputText value="#{sel.ico}" />
				</rich:column>
				<rich:column width="120px">
					<h:outputText value="#{sel.baseAddress.zip}" />
				</rich:column>
				<rich:column width="200px">
					<h:outputText value="#{sel.baseAddress.country}" />
				</rich:column>
				<rich:column width="200px">
					<h:outputText value="#{sel.baseAddress.streetName}" />
				</rich:column>
			</rich:dataTable>
		</rich:panel>

	</a4j:form>
</ui:composition>

</html>